#ifndef _CONNECTOR_MANAGER_HPP_20120424
#define _CONNECTOR_MANAGER_HPP_20120424

#ifdef _MULTIPLE_THREAD

#include <ext/hash_map>

#include "base.hpp"
#include "net_addr.hpp"
#include "lock.hpp"
#include "thread.hpp"
#include "socket_manager.hpp"

#include "buffer_alloc.hpp"

namespace mina
{
	template <typename _Connection>
	class ConnectorManager : public SocketManager<_Connection>, public thread::Thread
	{
		public :
			typedef _Connection Connection;
			typedef SocketManager<Connection> SockMgr;

		public :
			ConnectorManager(BufferAlloc * wr_alloc, BufferAlloc * rd_alloc,
						SockMgr * pMgr, int max_conn, long epoll_timeout)
				: SockMgr(wr_alloc, rd_alloc, max_conn, epoll_timeout),
				  thread::Thread("ConnectorManager")
			{
				_parent_mgr  = pMgr;
				start();
			}

			void run()
			{
				while (true)
				{
					SockMgr::poll(_parent_mgr);
				}
			}

		public :
			SockMgr  * _parent_mgr;
	};
}

#endif

#endif

